package org.dromara.xxmj.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.xxmj.domain.dto.ForgetPasswordDTO;
import org.dromara.xxmj.service.XxmjRegisterService;
import org.springframework.web.bind.annotation.*;

/**
 * 用户通用接口
 *
 * @param
 * @Author 王晨沣
 * @Date 2025-05-19 09:04:50 （可以根据需要修改）
 */
@Slf4j
@SaIgnore
@RequiredArgsConstructor
@RestController
@RequestMapping("/xxmj/general")
public class XxmjGeneralController {

    @Resource
    private XxmjRegisterService registerService;

    /**
     * 忘记密码
     *
     * @Author 王晨沣 2307105054
     * @Date 2025-05-17 15:55:30
     */
    @Operation(summary = "忘记密码")
    @PostMapping("/forgetPassword")
    public R<String> forgetPassword(@RequestBody @Valid ForgetPasswordDTO dto) {
        registerService.forgetPassword(dto);
        return R.ok("修改成功，请登录!");
    }

    /**
     * 用户注销
     *
     * @Author 王晨沣 2307105054
     * @Date 2025-05-22 17:27:33
     */
    @Operation(summary = "用户注销")
    @PostMapping("/userLogout/{code}")
    public R<Boolean> userLogout(@Parameter(description = "视频ID") @PathVariable String code) {
        registerService.userLogout(code);
        return R.ok("注销成功");
    }


}
